package com.cn.wanxi.service.impl;

import com.cn.wanxi.dao.ProductDao;
import com.cn.wanxi.dao.impl.ProductImpl;
import com.cn.wanxi.model.ProductModel;
import com.cn.wanxi.result.ResultModel;
import com.cn.wanxi.service.ProductService;

public class ProductServiceImpl implements ProductService {
    @Override
    public ResultModel findAll(ProductModel productModel) {
        ProductDao productDao = new ProductImpl();
        return ResultModel.getModel(productDao.getCount(productModel), productDao.findAll(productModel));
    }

    @Override
    public ResultModel del(ProductModel model) {
        ProductDao productDao = new ProductImpl();
        return ResultModel.getModel(productDao.del(model));
    }

    @Override
    public ResultModel add(ProductModel model) {
        ProductDao productDao = new ProductImpl();
        return ResultModel.getModel(productDao.add(model));
    }

    @Override
    public ResultModel findById(ProductModel model) {
        ProductDao productDao = new ProductImpl();
        return ResultModel.getModel(productDao.findById(model));
    }

    @Override
    public ResultModel update(ProductModel model) {
        ProductDao productDao = new ProductImpl();
        return ResultModel.getModel(productDao.update(model));
    }

    @Override
    public ResultModel getCount(ProductModel model) {
        ProductDao productDao = new ProductImpl();
        return ResultModel.getModel(productDao.getCount(model));
    }
}
